from datetime import datetime

from comment_analysis import *
from settings import *
if __name__ == '__main__':
    input_path = "../input/微博/以色列驻华使馆.csv"
    output_path = "."
    settings = Settings(input_path, output_path)
    # start_date, end_date = get_time_range()
    start_date = datetime.strptime("2024-1-1", '%Y-%m-%d').date()
    end_date = datetime.strptime("2024-2-2", '%Y-%m-%d').date()
    text, wordlist, stopwords_list, user_data = process_text(settings.input_path, settings.stopwords_list_path,
                                                             start_date, end_date)

    ca = CommentAnalysis(text, wordlist, stopwords_list, settings.output_path, settings.show, user_data)
    '''生成情感值统计柱状图'''
    ca.emotion_bar(settings.category)
    tend = ca.get_res['positive'] - ca.get_res['negative']
    '''生成词云'''
    if tend > 0:
        colormap = 'inferno'
    else:
        colormap = 'cool'
    ca.wordcloud(_background_path=settings.wordcloud_background_path, _width=1000, _height=800, _colormap=colormap)
    '''生成舆论时间变化折线图'''
    ca.time_line()
    '''生成ip属地分布图'''
    ca.ip_distribution()
